package com.jinmdz.fmis.mapper.mapper;

import com.jinmdz.fmis.mapper.entity.RoleMenuRelationEntity;
import com.jinmdz.fmis.mapper.mapper.provider.RoleMenuRelationProvider;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 角色菜单关联表Mapper
 *
 * @author generator
 * @date 2020-03-19 13:44
 */
public interface RoleMenuRelationMapper {

    /**
     * 增加RoleMenuRelation
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-19 13:44
     */
    @InsertProvider(type = RoleMenuRelationProvider.class, method = "insertRoleMenuRelation")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertRoleMenuRelation(@Param("entity") RoleMenuRelationEntity entity);

    /**
     * 删除RoleMenuRelation
     *
     * @param id             主键
     * @param modifiedUserId 修改用户外键
     * @param version        版本号
     * @return
     * @author generator
     * @date 2020-03-19 13:44
     */
    @Update(" update role_menu_relation set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForRoleMenuRelation(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改RoleMenuRelation
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-19 13:44
     */
    @UpdateProvider(type = RoleMenuRelationProvider.class, method = "updateRoleMenuRelation")
    void updateRoleMenuRelation(@Param("entity") RoleMenuRelationEntity entity);

    /**
     * 查询RoleMenuRelation实体
     *
     * @param id 主键
     * @return RoleMenuRelationEntity
     * @author generator
     * @date 2020-03-19 13:44
     */
    @Select(" select id,deleted,business_system_role_id,business_system_menu_id,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from role_menu_relation where id = #{id} and deleted = 0 limit 1 ")
    RoleMenuRelationEntity getRoleMenuRelationById(@Param("id") Integer id);

    /**
     * 查询RoleMenuRelation列表
     *
     * @param entity 数据实体
     * @return RoleMenuRelationEntity
     * @author generator
     * @date 2020-03-19 13:44
     */
    @SelectProvider(type = RoleMenuRelationProvider.class, method = "listRoleMenuRelation")
    ArrayList<RoleMenuRelationEntity> listRoleMenuRelation(@Param("entity") RoleMenuRelationEntity entity);
}